module.exports = function(grunt) {
	var language = 'zh-CN';
	var BASE_SYSTEM_JS_URL = "../resource/js",
		BASE_JS_LIB_URL = "../buijs/jslib";
	// 配置
	grunt.initConfig({
		pkg: grunt.file.readJSON('package.json'),

		requirejs: {
			options: {
				baseUrl: '.',
				paths: {
					broada: BASE_JS_LIB_URL,
					resource: "../resource",
					apm: BASE_SYSTEM_JS_URL,
					echarts: 'empty:',
					zrender: 'empty:',
					'broada/base/text': './text'
				},
				optimize: 'none',
				exclude: []
			},
			business_topo:{
				options: {
					name: 'apm/ui/business_topo',
					packages: [
						{
							name: 'apm/ui/business_topo',
							location: BASE_SYSTEM_JS_URL + "/ui/business_topo"
						}
					],
					out: BASE_SYSTEM_JS_URL + '/ui/business_topo.js'
				}
			},
			business_time_ranges:{
				options: {
					name: 'apm/ui/business_time_ranges',
					packages: [
						{
							name: 'apm/ui/business_time_ranges',
							location: BASE_SYSTEM_JS_URL + "/ui/business_time_ranges"
						}
					],
					out: BASE_SYSTEM_JS_URL + '/ui/business_time_ranges.js',
					exclude: [
						'broada/base/text',
						'broada/wijmo/wijcalendar/jquery.wijmo.wijcalendar'
					]
				}
			}
		},

		concat: {
			globaljs:{
				src: [
					BASE_SYSTEM_JS_URL + '/config.js',
					BASE_SYSTEM_JS_URL + '/loader.js'
				],
				dest: BASE_SYSTEM_JS_URL + '/global.js'
			},
			appjs:{
				src: [
					BASE_SYSTEM_JS_URL + '/starter.js',
					BASE_SYSTEM_JS_URL + '/store.js',
					BASE_SYSTEM_JS_URL + '/util.js',
					BASE_SYSTEM_JS_URL + '/authentication.js'
				],
				dest: BASE_SYSTEM_JS_URL + '/app.js'
			}
		},

		uglify: {
			globaljs: {
				src: BASE_SYSTEM_JS_URL + '/global.js',
				dest: BASE_SYSTEM_JS_URL + '/global.js'
			},
			appjs: {
				src: BASE_SYSTEM_JS_URL + '/app.js',
				dest: BASE_SYSTEM_JS_URL + '/app.js'
			},
			echartsall: {
				src: '../resource/echarts/echarts-all.source.js',
				dest: '../resource/echarts/echarts-all.js'
			},
			echartscus: {
				src: '../resource/echarts/echarts-customs.source.js',
				dest: '../resource/echarts/echarts-customs.js'
			},
			echarts: {
				src: '../resource/echarts/echarts.source.js',
				dest: '../resource/echarts/echarts.js'
			},
			business_topo: {
				src: BASE_SYSTEM_JS_URL + '/ui/business_topo.js',
				dest: BASE_SYSTEM_JS_URL + '/ui/business_topo.js'
			},
			business_time_ranges: {
				src: BASE_SYSTEM_JS_URL + '/ui/business_time_ranges.js',
				dest: BASE_SYSTEM_JS_URL + '/ui/business_time_ranges.js'
			}
		},

		cssmin: {
			// minify: {
			//	 expand: true,
			//	 cwd: './',
			//	 src: ['*.css', '!*.min.css'],
			//	 dest: './',
			//	 ext: '.min.css'
			// },
			minify: {
				files: {
					"../resource/css/global.css": [
						'../resource/css/global.css'
					]
				}
			}
		},

		copy: {
			main: {
				files: [
					//{expand: true, cwd: 'dist/', src: ['wijmo/**'], dest: dir_output}
					// {
					//	 src:['css/bootstrap.css'],
					//	 dest: dir_output + 'css/base.css'
					// }
				]
			}
		}
	});

	//载入插件
	grunt.loadNpmTasks('grunt-contrib-concat');
	grunt.loadNpmTasks('grunt-contrib-uglify');
	grunt.loadNpmTasks('grunt-contrib-requirejs');
	grunt.loadNpmTasks('grunt-contrib-less');
	grunt.loadNpmTasks('grunt-contrib-cssmin');
	grunt.loadNpmTasks('grunt-contrib-copy');
	//grunt.loadNpmTasks('grunt-jsdoc');

	// 注册任务
	grunt.registerTask('globaljs', [
		'concat:globaljs',
		'uglify:globaljs'
	]);
	grunt.registerTask('appjs', [
		'concat:appjs',
		'uglify:appjs'
	]);
	grunt.registerTask('echarts', [
		'uglify:echartsall',
		'uglify:echartscus',
		'uglify:echarts',
	]);
	grunt.registerTask('topo', [
		'requirejs:business_topo',
		'uglify:business_topo',
	]);
	grunt.registerTask('timerange', [
		'requirejs:business_time_ranges',
		'uglify:business_time_ranges',
	]);
	//grunt.registerTask('doc', ['jsdoc']);

};